package wibrst.utils {
	import flash.utils.ByteArray;
	/**
	 * ...
	 * @author wibrst@qq.com
	 */
	public class ByteUtil {
		
		static public function clone( oSrc:* ):* {
			var baClone:ByteArray = new ByteArray;
			baClone.writeObject( oSrc );
			baClone.position = 0;
			return baClone.readObject();
		}
		
		static public function copyBytes ( baTgt:ByteArray, posTgt:uint, baSrc:ByteArray, posSrc:uint, lenCopy:uint ) :void {
			if ( posSrc + lenCopy <= baSrc.length ) {
				if ( baSrc.position != posSrc ) baSrc.position = posSrc;
				baSrc.readBytes ( baTgt, posTgt, lenCopy ) ;
			}
		}
		
	}

}